<template>
	<div>
		<title-common v-if="config.showTitle" :config="config"></title-common>
		<div v-html="content" ></div>
	</div>
</template>

<script>
/**
 * 富文本组件
 */
import ComponentView from "@/views/modules/preview/components/common/component-view.js";
import ScreenViewManageApi from "@/api/screen/core/screen-view-manage.js";
export default {
	name: "quillEditor-view",
	mixins:[ComponentView],
	data() {
		return {
			content:"",
			params:{}
		}
	},
	methods: {
		getData(){
			let dataSources=this.config.dataSources;
			//是否为动态文本
			if(dataSources.source=='dynamic' && this.config.dataSources.dataModel && this.config.dataSources.measures&& this.config.dataSources.measures.length>0){
				let obj = {
					dataModel: dataSources.dataModel,
					measures:dataSources.measures,
					dimensions: [],
					colorLegends: [],
					params: this.params,
					filterParams: [],
					resultNum:this.config.dataSources.resultNum
				}
				let self = this;
				//获取数据
				ScreenViewManageApi.getData(JSON.stringify(obj)).then(res => {
					if( res && res.data && res.data.length>0){
						self.data = res.data;
						this.gestalt(self.data[0])
						self.content=this.formatTemplateField(dataSources.content,self.data[0])||dataSources.content;
					}else {
						self.content=dataSources.content;
					}
				});
			}else {
				this.content=dataSources.content || "";
			}
		},
	},
	watch: {}
}
</script>

<style scoped>
</style>
